package thread.sisuo.xiezuoduixiangsisuo;


import java.util.HashSet;
import java.util.Set;

public class Dispatcher {
    private final Set<Taxi> taxis;
    private final Set<Taxi> avaliableTaxis;

    public Dispatcher() {
        taxis = new HashSet<Taxi>();
        avaliableTaxis = new HashSet<Taxi>();
    }

    public synchronized void notifyAvaliable(Taxi taxi) {

        System.out.println("给当前对象添加到可用的出租车集合中");
        taxis.add(taxi);
    }

    public synchronized Image getImage() {

        Image image = new Image();
        for (Taxi t : taxis) {
            image.drawMarker(t.getLocation());
        }
        return image;
    }
}